package com.hzdl.car.mapper;

import com.hzdl.car.bean.Car;
import com.hzdl.car.sqlprovider.CarSqlProvider;
import com.hzdl.car.vo.CarVo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

@Mapper
public interface CarMapper {
    @SelectProvider(type = CarSqlProvider.class,method = "findCar")
    List<Car> findCar(CarVo carVo);
    @Delete("delete from bus_car where carNumber=#{carNumber}")
    int delCar(CarVo carVo);
    @Insert("insert into bus_car (carNumber,carType,color,price,rentPrice,deposit,isrenting,description,carimg,createTime) " +
            "values (#{carNumber},#{carType},#{color},#{price},#{rentPrice},#{deposit},#{isrenting},#{description}," +
            "#{carimg},now())")
    int addCar(CarVo carVo);
    @Update("update bus_car set carType=#{carType},color=#{color},price=#{price},rentPrice=#{rentPrice}," +
            "deposit=#{deposit},isrenting=#{isrenting},description=#{description},carimg=#{carimg} " +
            "where carNumber=#{carNumber}")
    int updateCar(CarVo carVo);
    @Update("update bus_car set isrenting=#{isrenting} where carNumber=#{carNumber}")
    int carIsRent(CarVo carVo);
    @Select("select * from bus_car where carNumber=#{carNumber}")
    Car findCarByNum(String CarNum);
    @Select("{call changNum(#{num,mode=OUT,jdbcType=INTEGER})}")
    @Options(statementType = StatementType.CALLABLE)
   Integer p(Map<String,Object> map);

}
